 
   window.googletag = window.googletag || {cmd: []};
   googletag.cmd.push(function() {
	   
	 googletag.defineSlot('/21954263161/scraper_code', [160, 600], 'div-gpt-ad-1586091016401-1').addService(googletag.pubads());
		   googletag.defineSlot('/21954263161/scraper_code', [160, 600], 'div-gpt-ad-1586091016401-2').addService(googletag.pubads());
			  googletag.pubads().enableSingleRequest();
	 googletag.pubads().collapseEmptyDivs();
	 googletag.enableServices();
   });

   (adsbygoogle = window.adsbygoogle || []).push({
	google_ad_client: "ca-pub-5027040478877022",
	enable_page_level_ads: true
  });

   if (screen.width <= 550) {//640
		//alert("mobile");//works!
		
		document.location = "https://www.sudoku.name/mobile.php?ln=cn&puzzle_num=25333&killer_sudoku=0";    	
    }
    var solve_window;
shown_arr1=new Array(0,0,1,0,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,1,0,0,1,1,0,0,1,0,1,0,1,0,0);
/*	
var cages_arr=new Array(1,1,2,2,2,3,4,5,6,
					   7,7,8,8,3,3,4,5,6,
					   7,7,9,9,3,16,10,10,
					   24,23,23,9,17,16,10,11,6,
					   24,25,25,22,17,16,10,11,15,
					   29,25,26,22,17,18,12,12,15,
					   29,26,26,22,21,18,18,13,13,
					   29,28,27,21,21,19,19,13,13,
					   19,28,27,21,20,20,20,14,14);
*/
//tmp_cages=new Array();//the js version of $tmp_cages

function check_grid()//id)
{
	empty=0;
	error=0;
	//check rows
	for (i=1;i<10;i++)
	{
		tmp_arr=new Array(0,0,0,0,0,0,0,0,0);
		start=1+((i-1)*9);
		finish=((i-1)*9)+10;
		for (j=start;j<finish;j++)//check cell of row
		{
			tmp=document.getElementById('c'+j).value;
			if (tmp!="")//disrigard empty cells
			{
				if (tmp_arr[tmp-1]==0) tmp_arr[tmp-1]=tmp;
				else 
				{
					//error
					//mark duplicaned cells
					for (j2=start;j2<finish;j2++)//check cell of row
					{
						if (((document.getElementById('c'+j2).value)==tmp)&&(shown_arr1[j2-1]!=1)) {
							document.getElementById('cell'+j2).bgColor= '#ff0000';
							bg_color_old_arr[j2]=document.getElementById('cell'+j2).bgColor;
						}
					}
					if ((document.getElementById('check_control_box').checked== false)&&(error==0)) 
					{
						alert ('一行内发现重复数字！');//only if no error before
						return;
					}
					error=1;
				}
			}
			else empty=1;
		}
	}//end check rows
	
	//check columns
	for (i=1;i<10;i++)
	{
		tmp_arr=new Array(0,0,0,0,0,0,0,0,0);
		start=i;
		finish=73+i;
		for (j=start;j<finish;j+=9)//check cell of column
		{
			tmp=document.getElementById('c'+j).value;
			if (tmp!="")//disrigard empty cells
			{
				if (tmp_arr[tmp-1]==0) tmp_arr[tmp-1]=tmp;
				else 
				{
					//error
					//mark duplicaned cells
					for (j2=start;j2<finish;j2+=9)//check cell of row
					{
						if (((document.getElementById('c'+j2).value)==tmp)&&(shown_arr1[j2-1]!=1)) 
						{
							document.getElementById('cell'+j2).bgColor= '#ff0000';
							bg_color_old_arr[j2]=document.getElementById('cell'+j2).bgColor;
						}
					}
					
					if ((document.getElementById('check_control_box').checked== false)&&(error==0)) 
					{
						alert ('一列内发现重复数字！');//only if no error before
						return;// false;
					}
					error=1;
				}
			}
			else empty=1;
		}
	}//end column check
	
	//check regions
	for (i=1;i<10;i++)
	{
		tmp_region=new Array(1,4,7,28,31,34,55,58,61);
		tmp_arr=new Array(0,0,0,0,0,0,0,0,0);
		start=tmp_region[i-1];
		finish=tmp_region[i-1]+21;
		for (j=start;j<finish;j+=9)//row
		{
			for (j1=j;j1<j+3;j1++)//column
			{
				tmp=document.getElementById('c'+j1).value;
				if (tmp!="")//disrigard empty cells
				{
					if (tmp_arr[tmp-1]==0) tmp_arr[tmp-1]=tmp;
					else 
					{
						//error
						//mark duplicaned cells
						for (j2=start;j2<finish;j2+=9)//row
						{
							for (j3=j2;j3<j2+3;j3++)//column
							{
								if (((document.getElementById('c'+j3).value)==tmp)&&(shown_arr1[j3-1]!=1)) 
								/*{
									document.getElementById('cell'+j3).bgColor= '#ff0000';
								}*/
								{
									document.getElementById('cell'+j3).bgColor= '#ff0000';
									//only for similar stuff
									bg_color_old_arr[j3]=document.getElementById('cell'+j3).bgColor;
								}
							}
						}
						
						if ((document.getElementById('check_control_box').checked== false)&&(error==0)) 
						{
							alert ('一区内发现重复数字！');//only if no error before
							return;// false;
						}
						error=1;
					}
				}
				else empty=1;
			}
		}
	}//end checking regions
	
	if ((empty==0)&&(error==0))//solved sudoku
	{
		var alert_string="您已经成功解答了这个數獨迷题！！！";
		var alert_string_timer="您的解答时间为";
		
		if (document.getElementById("timer").checked==true)
		{
			if (document.getElementById("time_limit").selectedIndex>0)
			{
				var startTime1=(document.getElementById('time_limit').value*60)-startTime;
				var hours = Math.floor(startTime1 / 3600);
				var minutes = Math.floor((startTime1 - hours*3600) / 60);
				var seconds = Math.floor((startTime1 - hours*3600 - minutes*60));
				var tmp="00" + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
			}
			else tmp= document.getElementById('show_time').innerHTML;
			
			alert_string+='\n'+alert_string_timer+' '+tmp;
			document.getElementById('stop_timer').value=1;
		}
		
		solving_time=document.getElementById('hide_timer_count').value;
	//$more_text89);//or this will be for spesific langs $play_sudoku_text3=str_ireplace($sudoku_str
		document.getElementById('stop_timer').value=1;//stop hidden watch
		document.getElementById('only_score').value="";
		document.getElementById('solve_flag').value="";
		//uncoment than mobile!
		solve_window=window.open("https://www.sudoku.name/solved-puzzle.php?ln=cn&puzzle_num=25333&solving_time="+solving_time+"&avarage=588&avarage_votes=25315&difficult=4&hash=29586cb449c90e249f1f09a0a4ee245a"+"&message_more19=提交"+"&message_more21=最多"+"&review_len=800"+"&message_more16=正在发送"+"&t=0&new_game_str=新游戏&killer_sudoku=0&killer_sudoku_str=杀手&sudoku_str=數獨&more_text89=杀手数独",'','width=728,height=610,scrollbars=yes,left=200,top=50');
		if (solve_window == null || typeof(solve_window)=='undefined')//should work when blocked. apply to desktop and frame version as well
		{
			//alert("Turn off your pop-up blocker!");
			window.location.href = "https://www.sudoku.name/solved-puzzle.php?ln=cn&puzzle_num=25333&solving_time="+solving_time+"&avarage=588&avarage_votes=25315&difficult=4&hash=29586cb449c90e249f1f09a0a4ee245a"+"&message_more19=提交"+"&message_more21=最多"+"&review_len=800"+"&message_more16=正在发送"+"&t=0"+"&back=1&new_game_str=新游戏&killer_sudoku=0&killer_sudoku_str=杀手&sudoku_str=數獨&more_text89=杀手数独";//back=1 indicates popup blocker. show back to main button.
		}
	}
			else if (error==0)
		{
			if (document.getElementById('check_control_box').checked== false) alert("未发现错误!");
		}
		} 
function move(e,id)
{
	var tmp_i=id;
	if(window.event) key = window.event.keyCode;
	else key = e.which;
	if (key==37)//left
	{
		if ((id==1)||(id==10)||(id==19)||(id==28)||(id==37)||(id==46)||(id==55)||(id==64)||(id==73))
		{
			//don't move left
		}
		else
		{
			tmp_i=id-1;
			flag=0;
			while (shown_arr1[tmp_i-1]==1)
			{
				if ((tmp_i==1)||(tmp_i==10)||(tmp_i==19)||(tmp_i==28)||(tmp_i==37)||(tmp_i==46)||(tmp_i==55)||(tmp_i==64)||(tmp_i==73)) 
				{
					flag=1;
					break;
				}
				tmp_i=tmp_i-1;
			}
			//move 1 cell left
			if (flag==0) 
			{
				document.getElementById('c'+(tmp_i)).focus();
				//higlight_regions(tmp_i);
			}
		}
	}
	else if (key==39)//right
	{
		if ((id==9)||(id==18)||(id==27)||(id==36)||(id==45)||(id==54)||(id==63)||(id==72)||(id==81))
		{
			//don't move left
		}
		else
		{
			tmp_id=parseInt(id);
			tmp_i=tmp_id+1;
			flag=0;
			while (shown_arr1[tmp_i-1]==1)
			{
				if ((tmp_i==9)||(tmp_i==18)||(tmp_i==27)||(tmp_i==36)||(tmp_i==45)||(tmp_i==54)||(tmp_i==63)||(tmp_i==72)||(tmp_i==81)) 
				{
					flag=1;
					break;
				}
				tmp_i=tmp_i+1;
			}
			//move 1 cell left
			if (flag==0) 
			{
				document.getElementById('c'+(tmp_i)).focus();
				//higlight_regions(tmp_i);
			}
		}
	}
	else if (key==38)//up
	{
		document.getElementById('cpad'+id).focus();
		//higlight_regions(tmp_i);
		
	}
	else if (key==40)//down
	{
		if ((id==73)||(id==74)||(id==75)||(id==76)||(id==77)||(id==78)||(id==79)||(id==80)||(id==81))
		{
			//don't move
		}
		else
		{
			tmp_id=parseInt(id);
			tmp_i=tmp_id+9;
			flag=0;
			while (shown_arr1[tmp_i-1]==1)
			{
				if ((tmp_i==73)||(tmp_i==74)||(tmp_i==75)||(tmp_i==76)||(tmp_i==77)||(tmp_i==78)||(tmp_i==79)||(tmp_i==80)||(tmp_i==81)) 
				{
					flag=1;
					break;
				}
				tmp_i=tmp_i+9;
			}
			//move 1 cell left
			if (flag==0) 
			{
				document.getElementById('cpad'+(tmp_i)).focus();
				//higlight_regions(tmp_i);
			}
		}
	}
	if ((flag==0)&&((document.getElementById("regions_control_box").checked==true)||(document.getElementById("similar_control_box").checked==true))) higlight_regions(tmp_i);
	//alert(key);
}
function move_small(e,id)
{
	var tmp_i=id;
	if(window.event) key = window.event.keyCode;
	else key = e.which;
	if (key==38)//up
	{
		if ((id==1)||(id==2)||(id==3)||(id==4)||(id==5)||(id==6)||(id==7)||(id==8)||(id==9))
		{
			//don't move
		}
		else
		{
			//move 1 cell up
			tmp_i=id-9;
			flag=0;
			while (shown_arr1[tmp_i-1]==1)
			{
				if ((tmp_i==1)||(tmp_i==2)||(tmp_i==3)||(tmp_i==4)||(tmp_i==5)||(tmp_i==6)||(tmp_i==7)||(tmp_i==8)||(tmp_i==9)) 
				{
					flag=1;
					break;
				}
				tmp_i=tmp_i-9;
			}
			if (flag==0) 
			{
				document.getElementById('c'+(tmp_i)).focus();
				//higlight_regions(tmp_i);
			}
		}
	}
	else if (key==40)//down
	{
		document.getElementById('c'+(id)).focus();
	}
	if ((flag==0)&&((document.getElementById("regions_control_box").checked==true)||(document.getElementById("similar_control_box").checked==true))) higlight_regions(tmp_i);
}
function check_enter(e){
	
	var key;
	var keychar;
	
	if (window.event) key = window.event.keyCode;
	else if (e) 
	{
		key = e.which;
	}
	else return true;
	keychar = String.fromCharCode(key);
	
	if (key==13)
	{
		
		//check_puzzle_num();
		/*if (document.getElementById('puzzle_num').value=="#25333"){
		document.getElementById('puzzle_num').value="";
		}*/
		// e.stopPropagation();
       // e.preventDefault();
		document.getElementById("new_game_button").click();
		//alert("enter pressed");
		return false;
		//return true;/submits the form
	}
	//else return false;
	else return true;
	
	//return true;//probably allows puzzle num typing
	
}
function valid_number(e,tmp_cell)
{
	var key;
	var keychar;
	tmp_i=tmp_cell;
	tmp_cell='cell'+tmp_cell;
	//alert("yes"+key);//del
	if (window.event) key = window.event.keyCode;
	else if (e) 
	{
		key = e.which;
	}
	else return true;
	keychar = String.fromCharCode(key);
	
	if ((key!="")&&((("123456789").indexOf(keychar) > -1)||(key==8)||(key==0)))//doesnt work for delete bacspace
	{
		//alert("valid_number");
		if (document.getElementById('mark').checked== true) 
		{
			document.getElementById(tmp_cell).bgColor= '#C1D1FF';
			bg_color_old_arr[tmp_i]=document.getElementById('cell'+tmp_i).bgColor;
		}
		else 
		{
			document.getElementById(tmp_cell).bgColor= '#FFFFFF';
			bg_color_old_arr[tmp_i]=document.getElementById('cell'+tmp_i).bgColor;
		}
		
		return true;
	}
	else return false;
}
function delete_marking(id)
{
	//alert("yes key up");
	//if empty cell remove marks, simple
	delete_marking_new();
	//we put it here, because del,backspace doesnt fire on keypress. 
	//alert(document.getElementById('c'+id).value+" "+id+" "+document.getElementById('cell'+id).bgColor);
	if ((document.getElementById('c'+id).value=="")&&(bg_color_old_arr[id]== '#C1D1FF')){
		//alert("yes");
		document.getElementById('cell'+id).bgColor= '#FFFFFF';
		//insert to old array
		bg_color_old_arr[id]=document.getElementById('cell'+id).bgColor;
	}
	
	//similar_save_check(id);
	if (document.getElementById("similar_control_box").checked==true)
	{
		//higlight_regions_clear();
		for (i=1;i<82;i++)//save old bg colors
		{
			document.getElementById('cell'+i).bgColor=bg_color_old_arr[i];//this will clear similar numbers
		}
		similar_save_check(id);
	}
	if (document.getElementById('check_control_box').checked== false) 
	{
	}
	else if (document.getElementById('check_control_box').checked== true){
		check_grid();//id);
	}
	//alert("'"+document.getElementById('c'+id).value+"'");
	//undo
	//if (document.getElementById('c'+id).value=)
	undo_arry_num.push(document.getElementById('c'+id).value);//value
	undo_arry_cell_id.push(id);//cell id
	
	
	
}
function delete_marking_new()
{
	for (i=1;i<82;i++)//repaint cells
	{
		if (document.getElementById('cell'+i).bgColor=='#ff0000') 
		{
			document.getElementById('cell'+i).bgColor= '';
			bg_color_old_arr[i]=document.getElementById('cell'+i).bgColor;
		}
	}
}
function reset_marking()
{
	for (i=1;i<82;i++)//repaint cells
	{
				if (shown_arr1[i-1]==1) document.getElementById('cell'+i).bgColor= '#E5E5E5';
		else 
		{
			document.getElementById('cell'+i).bgColor= '#FFFFFF';
			bg_color_old_arr[i]=document.getElementById('cell'+i).bgColor;
		}
					
	}
}
var startTime = 0;timer_count=0;
first_press=0;
function hide_timer()
{
	if (document.getElementById('stop_timer').value==0) 
	{
		timer_count++;
		document.getElementById('hide_timer_count').value=timer_count;
		timer_id=window.setTimeout(hide_timer, 1000);
	}
}
function count_up()
{
	if (document.getElementById('stop_timer').value==0) 
	{
		startTime++;
		document.getElementById('timer_time').value=startTime;
		var hours = Math.floor(startTime / 3600);
		var minutes = Math.floor((startTime - hours*3600) / 60);
		var seconds = Math.floor((startTime - hours*3600 - minutes*60));
		document.getElementById("show_time").innerHTML = (hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
		timer_id=window.setTimeout(count_up, 1000);
	}
}
function count_down()
{
	if (startTime==0) 
	{
		alert("时间到！");
		for (i=1;i<82;i++) document.getElementById('c'+i).readOnly=true;
	}
	else if (document.getElementById('stop_timer').value==0) 
	{
		startTime--;
		document.getElementById('timer_time').value=startTime;
		var hours = Math.floor(startTime / 3600);
		var minutes = Math.floor((startTime - hours*3600) / 60);
		var seconds = Math.floor((startTime - hours*3600 - minutes*60));
		document.getElementById("show_time").innerHTML = (hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes + ":" + (seconds < 10 ? "0" : "") + seconds;
		timer_id=window.setTimeout(count_down, 1000);
	}
}
function upload_change()
{
	document.show_upload_form.submit();
}
function difficult_select_change()
{
	
	val=document.getElementById("difficult_select").value;
	//alert("hello "+val);
	if (val==0) document.getElementById("embed").value=document.getElementById("embed_direct").value;
	//else document.getElementById("embed").value=document.getElementById("embed_daily1").value+val+document.getElementById("embed_daily2").value;
	else document.getElementById("embed").value=document.getElementById("embed_daily1").value;//+val+document.getElementById("embed_daily2").value;
}
var select_difficult=0;//indicates if change difficult/killer 
function difficult_change()
{
	tmp=document.getElementById("difficult").selectedIndex;
	//tmp1=document.getElementById("killer_sudoku").selectedIndex;
	//check_puzzle_num();
												  
	document.getElementById('puzzle_num').value="";
	select_difficult=1;
	reset_board1();									  
	
}
function limit_change(tmp)
{
	//if tmp, send cookie for timer
	if (document.getElementById("time_limit").selectedIndex>0) document.getElementById('timer').value=0;
	
	//if (document.getElementById("timer").checked==true)
	if (document.getElementById('timer').value==0)
	{
		document.getElementById('timer').value=1;
		document.getElementById("timer").checked=true;
		document.getElementById('timer_div').style.display='';//show timer
		document.getElementById('stop_timer').value=0;
		document.getElementById("t_stop_timer").checked=false;
		if (document.getElementById('hide_timer_count').value>0) clearTimeout(timer_id);//if already working destroy older interval
		
		timer_count=0;
		document.getElementById('hide_timer_count').value=0;
		
		if (document.getElementById("time_limit").selectedIndex>0)
		{
			
			if (document.getElementById('timer_flag').value==1) clearTimeout(timer_id);
			else document.getElementById('timer_flag').value=1;
			
			startTime = 60*document.getElementById('time_limit').value;
			count_down();
			hide_timer();
			
			tmp=document.getElementById('time_limit').value;
			
		}
		else 
		{
			if (document.getElementById('timer_flag').value==1) clearTimeout(timer_id);
			else document.getElementById('timer_flag').value=1;
			
			startTime = 0;
			count_up();
			hide_timer();
		}
	}
	else
	{
		document.getElementById('timer').value=0;
		document.getElementById("timer").checked=false;
		document.getElementById('stop_timer').value=1;
		document.getElementById("t_stop_timer").checked=true;
		document.getElementById('timer_div').style.display='none';
	}
	
	if (tmp==1)//send timer cookie
	{
		var xmlhttp;
		var params = "timer_control="+document.getElementById('timer').value;//can be 0/1
		if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
		else if (window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4){}
		}
		xmlhttp.open("POST","ajax_timer_control.php",true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(params);
	}
}

function tmp_stop_timer()
{
	if (document.getElementById("t_stop_timer").checked==true) document.getElementById('stop_timer').value=1;//stop timer
	else if (document.getElementById("t_stop_timer").checked==false)//continue timer
	{
		document.getElementById('stop_timer').value=0;
		hide_timer();
		if (document.getElementById("time_limit").selectedIndex>0) count_down();
		else count_up();
	}
}
var erase_marks_flag=0;
function mark_check()
{
	if (document.getElementById('mark').value==0)//unchecked
	{
		document.getElementById('mark').value=1;
		document.getElementById("mark").checked=true;
		if (erase_marks_flag==0)
		{
			erase_marks_flag=1;
			document.getElementById('erase_marks_td').style.display='';
		}
	}
	else
	{
		document.getElementById('mark').value=0;
		document.getElementById("mark").checked=false;
		
	}
	
}
function mouse_check()
{
	if (document.getElementById("mouse_control_box").checked==true) document.getElementById("mouse_control_box").checked=false;
	else document.getElementById("mouse_control_box").checked=true;
	mouse_control_ajax();
}
function highlight_click(tmp)
{
	//var tmp_str=tmp;
	if (document.getElementById(tmp+'_control_box').checked==true) document.getElementById(tmp+'_control_box').checked=false;
	else document.getElementById(tmp+'_control_box').checked=true;
	//alert(tmp+'_control_box');
	control_ajax(tmp);
}
	
function control_ajax(tmp)
{
	var tmp_str=tmp;
	if (document.getElementById(tmp+'_control_box').checked==true) tmp=1;//mouse=1
	else tmp=2;
	
	var xmlhttp;
	var params = "tmp_var="+tmp_str+"&"+tmp_str+"_control="+tmp;//"mouse_control="+mouse;
	if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
	else if (window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4){}
	}
	xmlhttp.open("POST","ajax_control.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}	

function open_num_board(tmp,y,x,type)
{
	if (document.getElementById('hide_timer_count').value==0) hide_timer();
	
	//type 1=number 2=pad
	if (document.getElementById("mouse_control_box").checked==true) 
	{
		window.setTimeout(function () { document.getElementById('mouse_board_div').style.display=''; }, 0);
		document.getElementById('mouse_var').value=tmp;
		//higlight_regions(tmp);
		
		if (type==1) 
		{
			document.getElementById('cpad_pad').style.display='none';
			document.getElementById('cpad_var').value="";
		}
		else if (type==2) 
		{
			document.getElementById('cpad_pad').style.display='';//pad visual
			document.getElementById('cpad_var').value=1;
			document.getElementById('cpad_val').value=document.getElementById('cpad'+tmp).value;
		}
		
		if ((x>=0)&&(x<=2)) document.getElementById('mouse_board_div').style.left=(x*35)+24;
		else if ((x>=3)&&(x<=5)) document.getElementById('mouse_board_div').style.left=(x*35)+24+3;
		else if ((x>=6)&&(x<=8)) document.getElementById('mouse_board_div').style.left=(x*35)+24+6;		
		
		if ((y>=0)&&(y<=2)) document.getElementById('mouse_board_div').style.top=(y*35)+26;
		else if ((y>=3)&&(y<=5)) document.getElementById('mouse_board_div').style.top=(y*35)+26+3;
		else if ((y>=6)&&(y<=8))
		{
			if (type==1) document.getElementById('mouse_board_div').style.top=((y-2)*35)-26+12;
			else if (type==2) document.getElementById('mouse_board_div').style.top=((y-2)*35)-42;
		}
	}
	
	if ((document.getElementById("regions_control_box").checked==true)||(document.getElementById("similar_control_box").checked==true)) higlight_regions(tmp);
	//if (document.getElementById("similar_control_box").checked==true) higlight_regions(tmp);
}
function mouse_control_ajax()
{
	if (document.getElementById('mouse_control_box').checked==true) mouse=1;
	else mouse=2;
	
	var xmlhttp;
	var params = "mouse_control="+mouse;
	if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
	else if (window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4){}
	}
	xmlhttp.open("POST","ajax_mouse_control.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}
function check_ajax()
{
	if (document.getElementById('check_control_box').checked==true) check=1;
	else check=2;
	
	var xmlhttp;
	var params = "check_control="+check;
	if (window.XMLHttpRequest)
	{
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4){}
	}
	xmlhttp.open("POST","ajax_check_control.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
	
	if (check==1) check_control_ajax();
}
function check_control_ajax()
{
	delete_marking_new();
	check_grid();
}
function put_num_mouse(tmp)
{
	place=document.getElementById('mouse_var').value;
	if (document.getElementById('cpad_var').value=="")//regular num
	{
		document.getElementById('c'+place).value=tmp;
		
		undo_arry_num.push(tmp);//value
		undo_arry_cell_id.push(place);//cell id
		
		document.getElementById('mouse_board_div').style.display='none';
		//if (document.getElementById('mark').checked==true) 
		
		/*
		if (tmp!=""){//real num
			if (document.getElementById('mark').checked==true)
			{
				document.getElementById('cell'+place).bgColor='#C1D1FF';
				bg_color_old_arr[place]=document.getElementById('cell'+place).bgColor;
			}
			else 
			{
				document.getElementById('cell'+place).bgColor='#FFFFFF';
				bg_color_old_arr[place]=document.getElementById('cell'+place).bgColor;
			}
		}
		else{//delete
			document.getElementById('cell'+place).bgColor='#FFFFFF';
			bg_color_old_arr[place]=document.getElementById('cell'+place).bgColor;
		}
		*/
		if ((document.getElementById('mark').checked==false)||(tmp=="")){
			document.getElementById('cell'+place).bgColor='#FFFFFF';
			bg_color_old_arr[place]=document.getElementById('cell'+place).bgColor;
		}
		else if (document.getElementById('mark').checked==true){
			document.getElementById('cell'+place).bgColor='#C1D1FF';
				bg_color_old_arr[place]=document.getElementById('cell'+place).bgColor;
		}
			
		if (document.getElementById("similar_control_box").checked==true)
		{
			higlight_regions_clear();
			similar_save_check(place);
		}

		
		document.getElementById('c'+place).focus();
		if (document.getElementById('check_control_box').checked==true) 
		{
			check_control_ajax();
		}
	}
	else if (document.getElementById('cpad_var').value=="1")//pad num
	{
		
		if (tmp!="") document.getElementById('cpad'+place).value+=tmp;
		else 
		{
			tmp_str=document.getElementById('cpad'+place).value;//=n=str.slice(1,5);
			tmp_str_length=tmp_str.length;
			tmp_str=tmp_str.slice(0,tmp_str_length-1);
			document.getElementById('cpad'+place).value=tmp_str;
			
		}
		document.getElementById('cpad_val').value=document.getElementById('cpad'+place).value;
	}
}

bg_color_old_arr=new Array();//hold bg colors without highlight colors(redish or greenish)
bgcolor_flag=0;
function higlight_regions_clear()
{
	if (bgcolor_flag==1)//second paint or bigger
	{
		for (i=1;i<82;i++)//save old bg colors
		{
			
			//if (document.getElementById("similar_control_box").checked==true) 
			
			document.getElementById('cell'+i).bgColor=bg_color_old_arr[i];//this will clear similar numbers
			
			document.getElementById('cell'+i).style.backgroundImage='';//should clear highlights

		}
	}
	
}
function similar_save_check(place)
{
	
	for (i=1;i<82;i++)//save old bg colors
	{
		bg_color_old_arr[i]=document.getElementById('cell'+i).bgColor;

	}
	
	if (document.getElementById("similar_control_box").checked==true)//activate only for similars
	{
		tmp=document.getElementById('c'+place).value;
		
		if ((tmp!="")&&(tmp!=" "))
		{
			for (i=1;i<82;i++)
			{
				if ((tmp==document.getElementById('c'+i).value)&&(document.getElementById('cell'+i).bgColor!="#ff0000")) {
					document.getElementById('cell'+i).bgColor="#F0FF00";
					//alert("yes");
					//document.getElementById('cage_sum_'+i).style.backgroundColor = "#F0FF00";//.bgColor="#F0FF00";
					
					
					bgcolor_flag=1;
				}

			}
		}
		//check if has number, no number should be called on PUT_NUM or valid num
	}
}
function higlight_regions(place)
{
	
	higlight_regions_clear();
	similar_save_check(place);
	//now mark regions
	if (document.getElementById("regions_control_box").checked==true)
	{
		tmp_row=Math.floor((place-1)/9);//this is the row: 0-8
		tmp_col=place-(tmp_row*9);//this is the row 1-9
		tmp_region=(Math.floor(tmp_row/3))*3+(Math.floor((tmp_col-1)/3));//0-8

		//paint row
		tmp_i=(tmp_row*9)+1;
		for (i=tmp_i;i<tmp_i+9;i++)//save old bg colors
		{
			document.getElementById('cell'+i).style.backgroundImage='url(pictures/highlight-regions.png)';
		}
		//paint col
		tmp_i=tmp_col;
		while (tmp_i>0) tmp_i-=9;
		tmp_i+=9;//last cell
		while (tmp_i<=81)
		{
			document.getElementById('cell'+tmp_i).style.backgroundImage='url(pictures/highlight-regions.png)';
			tmp_i+=9;
		}

		//paint region
		region_arr=new Array(1,4,7,28,31,34,55,58,61);
		i=tmp_region;
		start=region_arr[i];
		finish=region_arr[i]+21;
		for (j=start;j<finish;j+=9)//row
		{
			for (j1=j;j1<j+3;j1++)//column
			{
				document.getElementById('cell'+j1).style.backgroundImage='url(pictures/highlight-regions.png)';
			}
		}

		bgcolor_flag=1;
	}//if ((document.getElementById("regions_control_box").checked==true)
}
function cell_focus()
{
	document.getElementById('mouse_board_div').style.display='none';
	tmp=document.getElementById('mouse_var').value;
	if (document.getElementById('cpad_var').value=='1') document.getElementById('cpad'+tmp).focus(); 
	else document.getElementById('c'+tmp).focus();
}
function max_comment()
{
	if (document.getElementById('comment').value.length>=799)
	{
		tmp= document.getElementById('comment').value;
		tmp=tmp.substring(0,799);
		document.getElementById('comment').value=tmp;
		document.getElementById('char_limit').value=0;
	}
	else document.getElementById('char_limit').value=800-document.getElementById('comment').value.length;
}
function send_comments_ajax(real_comment)
{
	if (document.getElementById('comment').value.length==0)
	{
		 alert('注释为空！');
	}
	else
	{
		//check repetitive vars
		str1=document.getElementById('comment').value;
		for (i=0;i<str1.length;i++)
		{
			tmp_chr=str1.charAt(i);
			j=i+1;
			count=1;
			
			while(tmp_chr==str1.charAt(j))
			{
				j++;
				count++;
			}
			
			if (count>2)
			{
				var new_str="";
				//left section of word
				for (x=0;x<=i+2;x++) new_str+=str1.charAt(x);
				//right section
				for (y=i+count;y<=str1.length;y++) 
				{
					new_str+=str1.charAt(y);
				}
				str1="";
				for (k=0;k<new_str.length;k++) str1+=new_str.charAt(k);
			}
		}
		document.getElementById('comment').value=str1;
		//end repetitive vars
		var xmlhttp;
		document.getElementById('searching_animate').style.display='';
		document.getElementById('comment_id').style.display='none';	

		tmp_comment=document.getElementById('comment').value;
		var intIndexOfMatch = tmp_comment.indexOf( "+" );
		// Loop over the string value replacing out each matching
		// substring.
		while (intIndexOfMatch != -1){
		// Relace out the current instance.
		tmp_comment = tmp_comment.replace( "+", "%2B" )
		// Get the index of any next matching substring.
		intIndexOfMatch = tmp_comment.indexOf( "+" );
		}
		only_score=document.getElementById('only_score').value;
		var params = "comment="+tmp_comment+"&direct_id=25333&user_generated=0"+"&hash_code=29586cb449c90e249f1f09a0a4ee245a"+"&ln=cn"+"&difficult=4"+"&only_score="+only_score+"&real_comment="+real_comment+"&killer_sudoku=0";
		
		
		
		//alert(params);
		if (window.XMLHttpRequest)
		{
			xmlhttp=new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		xmlhttp.onreadystatechange=function()
		{
			if(xmlhttp.readyState==4)
			{
				document.getElementById('searching_animate').style.display='none';
									//probably came from solved page(check against mobile stuff)
					if (real_comment!=1) real_comment=1;
									if (real_comment==1){
					document.getElementById('new_comment').style.display='';
					document.getElementById("new_comment_div").innerHTML =xmlhttp.responseText;
					
				}
				
				if (document.getElementById('solve_flag').value==1)
				{
					solve_window.document.getElementById('tr_comment_div').style.display='none';
					solve_window.document.getElementById('after_sent').style.display='';
				}
			}
		}
		xmlhttp.open("POST","comment_ajax.php",true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(params);
	}
}
	
var flag_start=0;
var start = new Date();

function initialize_page(){
			user_sudoku_upload();
	//upload_pandemiac();
	
	//alert("yes");
		
}

var first_time_members=0;
function members_modal(tmp){
	//alert("yes "+first_time_members);
	if (first_time_members==0){

		document.getElementById('members_animation').style.display='';
		
		var xmlhttp;
		var params = "ln=cn&modal_source_page=index";
		if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();}
		else if (window.ActiveXObject) {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}

		xmlhttp.onreadystatechange=function()
		{
			if(xmlhttp.readyState==4)
			{
				document.getElementById('members_animation').style.display='none';
				
				var txt =xmlhttp.responseText;
				document.getElementById("members_div").innerHTML =txt;
				
				var loader_7 = document.getElementById('like_us_loader7');//subscribe_modal');//
				document.getElementById("like_us7").appendChild(loader_7);
				first_time_members=1;
				new_members_modal();
			}
		}
		xmlhttp.open("POST","message_modal.php",true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(params);
	}
	else new_members_modal();
}
function new_members_modal(tmp)
{
	document.getElementById('members_modal').style.display='block';
	document.getElementById("like_us7").style.position = "fixed";
	document.getElementById('like_us7').style.display='block';
	document.getElementById('like_us_loader7').style.display='block';
	document.getElementById("like_us7").style.top = '60px';
}
function close_members_div(tmp)
{
	if (tmp==2)
	{
		document.getElementById('like_us_loader7').style.display='none';
		document.getElementById("like_us7").style.position = "absolute";
		document.getElementById("like_us7").style.top = '0px';
		document.getElementById('like_us7').style.display='none';
		document.getElementById('members_modal').style.display='none';
	}
}
	

var first_time_subscribe=0;
function show_subscribe_modal(tmp)//guests
//function show_subscribe_modal(tmp,txt)//guests
{
	
	if (first_time_subscribe==0)
	{
		if (tmp==1){
			document.getElementById('remove_ads_x').style.display='none';
			document.getElementById('upload_remove_ads_animation').style.display='';
		}
		else if (tmp==2){//this is 3 on mobile.php
			document.getElementById('upload_remove_ads_animation_block').style.display='';
		}
		
		//ga('send', {hitType: 'event',eventCategory: 'Click',eventAction: 'Subscription click',eventLabel: 'Desktop guest click remove ads'+txt+' cn'});
		var xmlhttp;
		var params = "ln=cn";
		if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();}
		else if (window.ActiveXObject) {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}

		xmlhttp.onreadystatechange=function()
		{
			if(xmlhttp.readyState==4)
			{
				if (tmp==1){
					document.getElementById('remove_ads_x').style.display='';
					document.getElementById('upload_remove_ads_animation').style.display='none';
				}
				else if (tmp==2){
					document.getElementById('upload_remove_ads_animation_block').style.display='none';
				}
				
				var txt =xmlhttp.responseText;
				document.getElementById("remove_ads_div").innerHTML =txt;
				
				var loader_6 = document.getElementById('like_us_loader6');//subscribe_modal');//
				document.getElementById("like_us4").appendChild(loader_6);
				first_time_subscribe=1;
				new_show_subscribe_modal();
			}
		}
		xmlhttp.open("POST","ajax_remove_ads.php",true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(params);
	}
	else new_show_subscribe_modal();
}
function new_show_subscribe_modal(tmp)
{
	document.getElementById('subscribe_modal').style.display='block';
	document.getElementById("like_us4").style.position = "fixed";//"absolute";
	document.getElementById('like_us4').style.display='block';
	document.getElementById('like_us_loader6').style.display='block';
	document.getElementById("like_us4").style.top = '60px';
}
function close_shop_div(tmp)
{
	if (tmp==2)
	{
		document.getElementById('like_us_loader6').style.display='none';
		document.getElementById("like_us4").style.position = "absolute";
		document.getElementById("like_us4").style.top = '0px';
		document.getElementById('like_us4').style.display='none';
		document.getElementById('subscribe_modal').style.display='none';
	}
}
function user_sudoku_upload()
{
	var xmlhttp;
	var params = "ln=cn"+"&dir_str=ltr"+"&float_dir_left=left"+"&message_more_text4=%E6%9C%80%E6%96%B0%E4%B8%8A%E8%BD%BD"+"&uploads_show="+"&message_more_text7=%E6%98%BE%E7%A4%BA%E5%85%A8%E9%83%A8"+"&diff_text1=%E5%AE%B9%E6%98%93"+"&diff_text2=%E4%B8%AD%E7%AD%89"+"&diff_text3=%E5%9B%B0%E9%9A%BE"+"&float_dir_right=right"+"&month1_text=正月"+"&month2_text=二月"+"&month3_text=三月"+"&month4_text=四月"+"&month5_text=五月"+"&month6_text=六月"+"&month7_text=七月"+"&month8_text=八月"+"&month9_text=九月"+"&month10_text=十月"+"&month11_text=十一月"+"&month12_text=十二月"+"&half_star1=half_star"+"&message_more_text10=差"+"&message_more_text11=中下"+"&message_more_text12=中等"+"&message_more_text13=好"+"&message_more_text14=杰出"+"&message_more_text29=新数独数字"+"&message_more_text30=至所有会员"+"&puzzle_num_str=25333"+"&row_puzzle_hash=29586cb449c90e249f1f09a0a4ee245a"+"&message_more_text17=发布评论"+"&message_more_text18=评论"+"&message_more_text19=提交"+"&message_more_text20=取消"+"&message_more_text21=最多"+"&review_len=800"+"&message_more_text16=正在发送"+"&message_more_text24=评论"+"&message_more_text27=客户"+"&message_more_text25=报告"+"&message_more_text26=更多评论"+"&message_more_text38=级别"+"&more_text39=男性"+"&more_text40=女性"+"&more_text41=在线访客"+"&more_text42=最近访客"+"&top_str=热门"+"&new_str=最新"+"&top_sudoku_puzzles_str=热门数独游戏"+"&new_sudoku_puzzles_str=最新数独游戏"+"&full_lang=1"+"&message_more_text5=%E4%B8%8A%E8%BD%BD%E4%BD%A0%E7%9A%84%E6%95%B0%E7%8B%AC"+"&message_more_text6=%E6%9B%B4%E5%A4%9A%E6%95%B0%E7%8B%AC%E4%B8%8A%E8%BD%BD"+"&shadow_right=2px"+"&shadow_left=-2px"+"&message_index7=分数"+"&message_index8=更多分数"+"&killer_sudoku=0"+"&killer_sudoku_str=杀手";
	
if (window.XMLHttpRequest)
{
	xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
	alert("Your browser does not support XMLHTTP!");
}
xmlhttp.onreadystatechange=function()
{
	if(xmlhttp.readyState==4)
	{
		var txt =xmlhttp.responseText;
		data = txt.split( "[BBB]" );
		document.getElementById("upload_user_sudoku_div").innerHTML =data[0];
		document.getElementById("users_div").innerHTML =data[1];
		document.getElementById("ajax_comments_div").innerHTML =data[2];
		/*var offsets = document.getElementById('comments_container').getBoundingClientRect();
		var top = offsets.top;
		var height=document.getElementById('comments_container').offsetHeight;
		*/
		var offsets = document.getElementById('upload_user_sudoku_div').getBoundingClientRect();
		var top = offsets.top;
		var height=document.getElementById('upload_user_sudoku_div').offsetHeight;
		
		//upload_user_sudoku_div
		var offsets1 = document.getElementById('users_div_height').getBoundingClientRect();
		var top1 = offsets1.top;
		var height1=document.getElementById('users_div_height').offsetHeight;
		//document.getElementById('users_div_height').style.height=parseInt(top+height-top1-27)+'px';
		document.getElementById('users_div_height').style.height='250px';
		document.getElementById('rate_div').style.display='';
		
		initial();
		
		//amazon_ads();
	}
}
xmlhttp.open("POST","ajax_user_upload_sudoku.php",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);
			
	
	}

function visitor_details(tmp)
{
	document.getElementById('visitor_details_upload').style.display='';
	document.getElementById('visitor_details_div').style.display='none';
		
	var xmlhttp;
	var params = "ln=cn"+"&user_id="+tmp+"&message_more_text38=级别"+"&more_text39=男性"+"&more_text40=女性"+"&more_text43=阅读更多"+"&more_text44=难题已解决"+"&more_text45=容易"+"&more_text46=中等"+"&more_text47=困难"+"&more_text48=年龄"+"&more_text49=最爱的难度等级&no_ads=";	
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			document.getElementById('visitor_details_upload').style.display='none';
			document.getElementById('visitor_details_div').style.display='';
			document.getElementById("visitor_details_div").innerHTML =xmlhttp.responseText;
		}
	}
	xmlhttp.open("POST","visitor_details_ajax.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}
function visitor_details_comments(tmp,i)
{
	document.getElementById('visitor_details_comments_flag_'+i).value=1;
	var xmlhttp;
	var params = "ln=cn"+"&user_id="+tmp+"&message_more_text38=级别"+"&more_text39=男性"+"&more_text40=女性"+"&more_text43=阅读更多"+"&more_text44=难题已解决"+"&more_text45=容易"+"&more_text46=中等"+"&more_text47=困难"+"&more_text48=年龄"+"&more_text49=最爱的难度等级&no_ads=";	
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			document.getElementById('visitor_details_upload_comments_'+i).style.display='none';
			document.getElementById('visitor_details_div_comments_'+i).innerHTML =xmlhttp.responseText;
			document.getElementById('visitor_details_div_comments_'+i).style.display='';
		}
	}
	xmlhttp.open("POST","visitor_details_ajax.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}
function turnoff_visitor()
{
	tmp_id=document.getElementById('visitor_details_id_light').value;
    document.getElementById('small_visitor_'+tmp_id).style.backgroundColor='#fff';
	document.getElementById('visitor_details').style.display='none';
	clearTimeout(userTimer);
}
function highlight_visitors(user_id)
{
	document.getElementById('visitor_details_id_light').value=user_id;
	document.getElementById('small_visitor_'+user_id).style.backgroundColor='#eee';
	document.getElementById('small_visitor_'+user_id).style.cursor='pointer';
	
	userTimer = setTimeout(function(){visitor_details(user_id)},300);//250);
	document.getElementById('visitor_details').style.display=''; 
	document.getElementById('visitor_details_div').style.display='none';
	document.getElementById('visitor_details_upload').style.display='';

	var offsets = document.getElementById('users_div_height').getBoundingClientRect();
	var top = offsets.top;//top of users div, this should stay the same all the time	
	var offsets1 = document.getElementById('small_visitor_'+user_id).getBoundingClientRect();
	var top1 = offsets1.top;

	document.getElementById('visitor_details').style.top=top1-top; 
	
}
timer_id=window.setTimeout(hide_timer, 1000);clearTimeout(timer_id);

function highlight_visitors_comments(user_id,i)
{
	tmp=document.getElementById('visitor_details_comments_flag_'+i).value;
	document.getElementById('visitor_details_comments_'+i).style.display=''; 
	if (tmp==1)
	{
		document.getElementById('visitor_details_upload_comments_'+i).style.display='none';
		document.getElementById('visitor_details_div_comments_'+i).style.display='';
	}
	else
	{
		document.getElementById('visitor_details_upload_comments_'+i).style.display='';
		document.getElementById('visitor_details_div_comments_'+i).style.display='none';
		visitor_details_comments(user_id,i);
	}
}
function turnoff_visitor_comments(i)
{
	document.getElementById('visitor_details_comments_'+i).style.display='none';
}

function addEvent(obj, type, fn) {
	if (obj.addEventListener)
		obj.addEventListener(type, fn, false);
	else if (obj.attachEvent)
		obj.attachEvent('on' + type, function() { return fn.apply(obj, [window.event]);});
}
addEvent(window, 'click', function(e){
	mouse_board_div = document.getElementById("mouse_board_div");
	mouse_board_div4 = document.getElementById("undo_div");
	var target = e.target || e.srcElement;
	if (target !== mouse_board_div && !isChildOf(target, mouse_board_div)) {
		if(mouse_board_div.style.display!='none') mouse_board_div.style.display='none';
	}
	
	if (bgcolor_flag==1){
		sudoku_board_div = document.getElementById("sudoku_main_board");
		var target = e.target || e.srcElement;
		if (target !== sudoku_board_div && !isChildOf(target, sudoku_board_div) && target !== mouse_board_div && !isChildOf(target, mouse_board_div)&&(target !== mouse_board_div4 && !isChildOf(target, mouse_board_div4))) {
			 higlight_regions_clear();
		}
	}
});
function isChildOf(child, parent) {
    if (child.parentNode === parent) {
      return true;
    } else if (child.parentNode === null) {
      return false;
    } else {
      return isChildOf(child.parentNode, parent);
    }
}
function ajax_upload_puzzles(tmp)
{
	document.getElementById('user_puzzles_div').style.display='none';
	document.getElementById('upload_user_puzzles_div').style.display='';
	
	var e = document.getElementById("uploads_show");
	var tmp1 = e.options[e.selectedIndex].value;
	
	var uploads_show_str=tmp1;//"";
	//var tmp_sort_str="";
	if (tmp=="new") 
	{	
		document.getElementById('new_1').style.display='none';
		document.getElementById('new_2').style.display='block';
		document.getElementById('top_1').style.display='none';
		document.getElementById('top_2').style.display='block';
	}
	else if (tmp=="top") 
	{	
		document.getElementById('new_1').style.display='block';
		document.getElementById('new_2').style.display='none';
		document.getElementById('top_1').style.display='block';
		document.getElementById('top_2').style.display='none';
	}
	else if (tmp=="upload_change")// ((tmp=="1")||(tmp=="2")||(tmp=="3")||(tmp=="4")||(tmp=="5"))
	{	
		uploads_show_str=tmp1;//document.getElementById("time_limit").value;//tmp;
		if (document.getElementById('new_1').style.display=='none') tmp="new";//so it knows to which subject relate
		else if (document.getElementById('new_1').style.display=='block') tmp="top";
	}
	
	var xmlhttp;
	var params = "ln=cn"+"&dir_str=ltr"+"&float_dir_left=left"+"&message_more_text4=%E6%9C%80%E6%96%B0%E4%B8%8A%E8%BD%BD"+"&message_more_text7=%E6%98%BE%E7%A4%BA%E5%85%A8%E9%83%A8"+"&diff_text1=%E5%AE%B9%E6%98%93"+"&diff_text2=%E4%B8%AD%E7%AD%89"+"&diff_text3=%E5%9B%B0%E9%9A%BE"+"&float_dir_right=right"+"&month1_text=正月"+"&month2_text=二月"+"&month3_text=三月"+"&month4_text=四月"+"&month5_text=五月"+"&month6_text=六月"+"&month7_text=七月"+"&month8_text=八月"+"&month9_text=九月"+"&month10_text=十月"+"&month11_text=十一月"+"&month12_text=十二月"+"&half_star=half_star"+"&message_more_text10=差"+"&message_more_text11=中下"+"&message_more_text12=中等"+"&message_more_text13=好"+"&message_more_text14=杰出"+"&message_more_text6=更多数独上载"+"&message_more_text5=上载你的数独"+"&sorting="+tmp+"&message_more_text15=投票"+"&uploads_show="+uploads_show_str+"&killer_sudoku=0";//+"&tmp_sort_str="+tmp_sort_str;
	//tmp_sort_str
	
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			document.getElementById('upload_user_puzzles_div').style.display='none';
			document.getElementById('user_puzzles_div').style.display='';
			var txt =xmlhttp.responseText;
			data = txt.split( "[BBB]" );//desktop 3 elemnts
	
			document.getElementById("user_puzzles_div").innerHTML =data[0]+data[2];//xmlhttp.responseText;
			
			document.getElementById("more_uploads_link").innerHTML =data[1];
		
		}
	}
	xmlhttp.open("POST","ajax_small_user_upload.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
	
}//function ajax_upload_puzzles(tmp)

function ajax_upload_comments(tmp)
{
	document.getElementById('user_comments_div').style.display='none';
	document.getElementById('upload_user_comments_div').style.display='';
	document.getElementById('new_comment').style.display='none';
	
	//new_comment
	//var e = document.getElementById("uploads_show");
	//var tmp1 = e.options[e.selectedIndex].value;
	
	//var uploads_show_str=tmp1;//"";
	//var tmp_sort_str="";
	if (tmp=="new") 
	{	
		document.getElementById('new_comments_1').style.display='none';
		document.getElementById('new_comments_2').style.display='block';
		document.getElementById('top_comments_1').style.display='none';
		document.getElementById('top_comments_2').style.display='block';
		
		document.getElementById('post_comment_div').style.display='';
		//post_comment_div
	}
	else if (tmp=="top") 
	{	
		document.getElementById('new_comments_1').style.display='block';
		document.getElementById('new_comments_2').style.display='none';
		document.getElementById('top_comments_1').style.display='block';
		document.getElementById('top_comments_2').style.display='none';
		
		document.getElementById('post_comment_div').style.display='none';
		document.getElementById('comment_id').style.display='none';
	}
	
	var xmlhttp;
	//$message_more_text38 ->level
	//+"&message_more_text4=%E6%9C%80%E6%96%B0%E4%B8%8A%E8%BD%BD"+"&message_more_text7=%E6%98%BE%E7%A4%BA%E5%85%A8%E9%83%A8"
	var params = "ln=cn"+"&dir_str=ltr"+"&float_dir_left=left"+"&message_more_text38=%E7%BA%A7%E5%88%AB"+"&float_dir_right=right"+"&month1_text=正月"+"&month2_text=二月"+"&month3_text=三月"+"&month4_text=四月"+"&month5_text=五月"+"&month6_text=六月"+"&month7_text=七月"+"&month8_text=八月"+"&month9_text=九月"+"&month10_text=十月"+"&month11_text=十一月"+"&month12_text=十二月"+"&message_more_text10=差"+"&message_more_text11=中下"+"&message_more_text12=中等"+"&message_more_text13=好"+"&message_more_text14=杰出"+"&message_more_text6=更多数独上载"+"&message_more_text15=投票"+"&sorting="+tmp+"&ln=cn"+"&puzzle_num_str=25333"+"&row_puzzle_hash=29586cb449c90e249f1f09a0a4ee245a"+"&message_more_text26=%E6%9B%B4%E5%A4%9A%E8%AF%84%E8%AE%BA"+"&message_index8=更多分数"+"&killer_sudoku_str=杀手";
	
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4)
		{
			document.getElementById('upload_user_comments_div').style.display='none';
			document.getElementById('user_comments_div').style.display='';
			
			
			var txt =xmlhttp.responseText;
			data = txt.split( "[BBB]" );//desktop 3 elemnts
			//alert(txt);
			//document.getElementById("user_comments_div").innerHTML =txt;
			document.getElementById("user_comments_div").innerHTML =data[0];//+data[2];//xmlhttp.responseText;
			
			document.getElementById("more_comments_link").innerHTML =data[1];
			if (data[1]=="") document.getElementById('more_comments_link').style.display='none';
			else document.getElementById('more_comments_link').style.display='block';
			
		}
	}
	xmlhttp.open("POST","ajax_small_comments_upload.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
	
}//function ajax_upload_puzzles(tmp)
	
function flag_ajax(tmp)
{
	
	//alert(tmp);
	//hide div
	document.getElementById('report_div'+tmp).style.display='none';
	
	//show sending div
	document.getElementById('send_report_div'+tmp).style.display='inline';
	//ajax
	var xmlhttp;
	

	//parameters to send
	var params = "message_id="+tmp+"&ln="+"cn";//+"&flags="+tmp_flags;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	
	xmlhttp.onreadystatechange=function()//what to do with Data recived fromserver
	{
		if(xmlhttp.readyState==4)//complete to recieve data
		{
			//alert(xmlhttp.responseText);
			//hide send rate div
			document.getElementById('send_report_div'+tmp).style.display='none';
			//show new rate div
			document.getElementById('report_div'+tmp).style.display='inline';
			document.getElementById("report_div"+tmp).innerHTML =xmlhttp.responseText;
			
		}
	}
	xmlhttp.open("POST","ajax_send_flag.php",true);//the script to run an who to send data(GET/POST)
	//xmlhttp.send(null);
	//Send the proper header information along with the request
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
	
}//function rate
	
num_empty_star=0;
num_half_star=0;
num_full_star=0;
num_full_star=3;
	num_half_star=1;num_empty_star=5-(num_full_star+num_half_star);
function initial()
{
	i=1;
	tmp_full_star=num_full_star;
	tmp_half_star=num_half_star;
	tmp_empty_star=num_empty_star;

	while(tmp_full_star>0){
		document.getElementById('star'+i).style.display="";
		document.getElementById('half-star'+i).style.display="none";
		document.getElementById('empty-star'+i).style.display="none";
		tmp_full_star--;
		i++;
	}

	while(tmp_half_star>0)	{
		document.getElementById('star'+i).style.display="none";
		document.getElementById('half-star'+i).style.display="";
		document.getElementById('empty-star'+i).style.display="none";
		tmp_half_star--;
		i++;
	}

	while(tmp_empty_star>0)	{
		document.getElementById('star'+i).style.display="none";
		document.getElementById('half-star'+i).style.display="none";
		document.getElementById('empty-star'+i).style.display="";
		tmp_empty_star--;
		i++;
	}
}
function rating(tmp)
{
	for (i=1;i<tmp+1;i++)//light all full stars
	{
		document.getElementById('star'+i).style.display="";
		document.getElementById('half-star'+i).style.display="none";
		document.getElementById('empty-star'+i).style.display="none";
	}

	for (i=tmp+1;i<6;i++){
		document.getElementById('star'+i).style.display="none";
		document.getElementById('half-star'+i).style.display="none";
		document.getElementById('empty-star'+i).style.display="";
	}
}
function rate(tmp){
	document.getElementById('rate_div').style.display='none';
	document.getElementById('send_rate_div').style.display='';
	var xmlhttp;
	var params = "id=25333&send_rating="+tmp+"&user_puzzle=0&ln=cn&killer_sudoku=0";
	//alert("yes");
	if (window.XMLHttpRequest) xmlhttp=new XMLHttpRequest();
	else if (window.ActiveXObject) xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4){
			document.getElementById('send_rate_div').style.display='none';
			document.getElementById('rate_div').style.display='';
			document.getElementById("rate_div").innerHTML =xmlhttp.responseText;
		}
	}
	xmlhttp.open("POST","ajax_send_rate.php",true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}//function rate
function check_puzzle_num(){
	
	//if similar to init, delete to let new puzzle to appear
	if (document.getElementById('puzzle_num').value=="#25333"){
		document.getElementById('puzzle_num').value="";
	}
	
	document.form1.submit();
}
function new_game_link(){
	var tmp;
	var puzzle_num=document.getElementById('puzzle_num').value;
	puzzle_num=puzzle_num.replace("#", "");
	var play=document.getElementById('play').value;
	var difficult=document.getElementById('difficult').value;
	var killer_sudoku=document.getElementById('killer_sudoku').value;
	//alert(killer_sudoku);
	var timer;
	if (document.getElementById("timer").checked==true) timer=1;
	else timer="";
	//var timer=document.getElementById('timer').value;
	//if (timer=="0") timer="";
	var time_limit=document.getElementById('time_limit').value;
	//var uploads_show=document.getElementById('uploads_show').value;
	
	//tmp="https://www.sudoku.name/killer-index4.php?ln=cn&puzzle_num="+puzzle_num+"&play="+play+"&difficult="+difficult+"&timer="+timer+"&time_limit="+time_limit+"&killer_sudoku=0";//+"&uploads_show="+uploads_show;
	//alert(killer_sudoku);
	tmp="https://www.sudoku.name/index.php?ln=cn&puzzle_num="+puzzle_num+"&play="+play+"&difficult="+difficult+"&timer="+timer+"&time_limit="+time_limit+"&killer_sudoku="+killer_sudoku;//+"&select_killer_sudoku=1"
	//if (select_difficult==1) tmp+="&select_killer_sudoku=1";
	return tmp;
}
function change_new_game(){
	
	
	//check_puzzle_num();//change puzzle num for rand
	if (document.getElementById('puzzle_num').value=="#25333"){
		document.getElementById('puzzle_num').value="";
	}
	/*var puzzle_num=document.getElementById('puzzle_num').value;//document.getElementById('puzzle_num').value;
	puzzle_num=puzzle_num.replace("#", "");
	var play=document.getElementById('play').value;
	var difficult=document.getElementById('difficult').value;
	var timer;
	if (document.getElementById("timer").checked==true) timer=1;
	else timer="";
	//var timer=document.getElementById('timer').value;
	//if (timer=="0") timer="";
	var time_limit=document.getElementById('time_limit').value;
	var uploads_show=document.getElementById('uploads_show').value;
	
	
	tmp="https://www.sudoku.name/tmp-index.php?ln=cn&puzzle_num="+puzzle_num+"&play="+play+"&difficult="+difficult+"&timer="+timer+"&time_limit="+time_limit+"&uploads_show="+uploads_show;
	//puzzle_num, play, difficult, timer, time_limit, uploads_show, 
	*/
	var tmp;
	tmp=new_game_link();
	/*document.getElementById("new_game_button").onclick = function() {
		alert("yes");
   var link = document.getElementById("new_game_button");
   link.setAttribute("href", tmp);
   return false;
   }
	*/
	var yourElement = document.getElementById('new_game_button');
 	yourElement.setAttribute('href', tmp);//'index-jp.php');//
	
	//new_ajaxFunction();
	return true;
}
/*function reset_board(){
	var tmp;
	tmp=new_game_link();
	
	var yourElement = document.getElementById('reset_button_id');
 	yourElement.setAttribute('href', tmp);
	return true;
}*/
function reset_board1(){
	var tmp;
	tmp=new_game_link();
	//var yourElement = document.getElementById('reset_button_id');
	var yourElement = document.getElementById('new_game_button');
 	yourElement.setAttribute('href', tmp);
	//document.getElementById('new_game_button').setAttribute( "onClick", "test_fn('111,222')" );
	document.getElementById('new_game_button').setAttribute( "onClick", "" );
	document.getElementById("new_game_button").click();
	//return false;//true;
}
//https://www.sudoku.name/puzzles/en/10/06f2e099b4f87109d52e15d7c05f0084/1/
function new_game_solved(){
	/*var tmp;
	tmp=new_game_link();
	//var yourElement = document.getElementById('reset_button_id');
	var yourElement = document.getElementById('new_game_button');
 	yourElement.setAttribute('href', tmp);
	//document.getElementById('new_game_button').setAttribute( "onClick", "test_fn('111,222')" );
	document.getElementById('new_game_button').setAttribute( "onClick", "" );*/
	document.getElementById("new_game_button").click();
	//return false;//true;
}
	
function game_restore(){
	var tmp;
	tmp=new_game_link();
	tmp+="&restore=1";
	var yourElement = document.getElementById('restore_id');
 	yourElement.setAttribute('href', tmp);
	return true;
}	
var undo_arry_num=new Array();
var undo_arry_cell_id=new Array();

function undo()
{
	//put if, length at least 1 size
	tmp=undo_arry_num.length-1;//;
	
	if (tmp>=0){
		last_num=undo_arry_num[tmp];//-1];
		last_cell=undo_arry_cell_id[tmp];//-1];
		//remove last cell
		undo_arry_num.pop();
		undo_arry_cell_id.pop();
		//check all cell array, look what was before
		flag_found=0;
		for (i=tmp;i>=0;i--){
			if (last_cell==undo_arry_cell_id[i]){//found previous value

				document.getElementById('c'+undo_arry_cell_id[i]).value=undo_arry_num[i];


				flag_found=1;
				break;
			}
		}
		if (flag_found==0){//didnt found, previous, leave it empty-similar to delete

			document.getElementById('c'+last_cell).value='';//undo_arry_num[i];
		}
		//Repaint
		document.getElementById('cell'+last_cell).bgColor='#FFFFFF';
		bg_color_old_arr[last_cell]=document.getElementById('cell'+last_cell).bgColor;
		if (document.getElementById("similar_control_box").checked==true)
		{
			higlight_regions_clear();
			similar_save_check(last_cell);
		}
		document.getElementById('c'+last_cell).focus();
		if (document.getElementById('check_control_box').checked==true) 
		{
			check_control_ajax();
		}
		
	}//if (tmp>=0){
}
	
function change_href(id)//simple sharing
{
	//tmp_link='https://www.sudoku.name/puzzles/cn/25333/29586cb449c90e249f1f09a0a4ee245a';
	tmp_link='https://www.sudoku.name/puzzles/cn/25333/29586cb449c90e249f1f09a0a4ee245a';
	//tmp_link='https://www.sudoku.name/d/en/1/Easy+killer+sudoku/1/';
	//d/en/1/Easy+killer+sudoku/1/
	
	if (id=="twit_id") document.getElementById(id).href='https://twitter.com/intent/tweet?text=%23%E5%9B%B0%E9%9A%BE%2B%2B+%23%E6%95%B8%E7%8D%A8+-+https%3A%2F%2Fwww.sudoku.name%2Fpuzzles%2Fcn%2F25333%2F29586cb449c90e249f1f09a0a4ee245a';
	else if (id=="whatsapp_id_desktop") document.getElementById(id).href='https://web.whatsapp.com/send?text=https%3A%2F%2Fwww.sudoku.name%2Fpuzzles%2Fcn%2F25333%2F29586cb449c90e249f1f09a0a4ee245a';
	else if (id=="naver_desktop") document.getElementById(id).href='https://share.naver.com/web/shareView.nhn?url=https%3A%2F%2Fwww.sudoku.name%2Fpuzzles%2Fcn%2F25333%2F29586cb449c90e249f1f09a0a4ee245a&title=%23%E5%9B%B0%E9%9A%BE%2B%2B+%23%E6%95%B8%E7%8D%A8';
	else if (id=="pinterest_id") document.getElementById(id).href='https://www.pinterest.com/pin/create/button/?url=https%3A%2F%2Fwww.sudoku.name%2Fpuzzles%2Fcn%2F25333%2F29586cb449c90e249f1f09a0a4ee245a&media=https%3A%2F%2Fwww.sudoku.name%2Fsudoku_face_share.php%3Fpuzzle_num%3D25333&h=320&w=320&description=%23%E5%9B%B0%E9%9A%BE%2B%2B+%23%E6%95%B8%E7%8D%A8';
	else if (id=="facebook_id") document.getElementById(id).href='https://www.facebook.com/dialog/share?app_id=622097744505434&href='+tmp_link+'&display=popup';

	//4ga('send', { hitType: 'event',eventCategory: "Puzzle Share", eventAction: id+' share',eventLabel: id+' simple puzzle sharing from website'});
}
window.fbAsyncInit = function() {
    FB.init({
      appId            : '622097744505434',
      autoLogAppEvents : true,
      xfbml            : true,
      version          : 'v18.0'
    });
  };
  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id; js.async=true;
     js.src = "https://connect.facebook.net/zh_CN/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));function language_change(){
lang=document.getElementById('language').value;
if (lang=="en") window.location = "https://www.sudoku.name";
else window.location = "https://www.sudoku.name/index-"+lang+".php";
}
function send_analytics(){
	//4ga('send', {hitType: 'event',eventCategory: 'Click',eventAction: 'Subscription click',eventLabel: 'Desktop guest click remove blocked ads cn'});
}
/*function send_analytics1(tmp_url,txt){//track member
	ga('send', {hitType: 'event',eventCategory: 'Click',eventAction: 'Subscription click',eventLabel: 'Desktop guest click remove ads'+txt+' cn'});	
	window.location.href = tmp_url;
	
}*/
	//change on mobile.php as w ell
var load_more_content_flag=0;
function isScrolledIntoView(){
	if (load_more_content_flag==0)//only one upload
	{
		var el=document.getElementById('sudoku_about_src');//bottom_ad');
		var rect = el.getBoundingClientRect();
		var elemTop = rect.top;
		var elemBottom = rect.bottom;

		// Only completely visible elements return true:
		//var isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight);
		// Partially visible elements return true:
		var isVisible = elemTop < window.innerHeight && elemBottom >= 0;
		//return isVisible;
		if (isVisible) 
		{
			load_more_content_flag=1;
						/* create frame with fresh content
			var ifrm = document.createElement("iframe");
			ifrm.setAttribute("src", "http://www.sudoku.name/more_links.php");
			ifrm.style.width = "100%";
			ifrm.style.height = "100%";
			ifrm.style.maxWidth = "900px"; 
			ifrm.style.maxHeight= "600px"; 
			ifrm.style.minHeight= "350px"; 
			
			//ifrm.style.minWidth = "400px"; 
			//ifrm.style.minHeight= "500px";

			ifrm.style.display = "block";
			ifrm.style.border = "0px";
			ifrm.setAttribute("id", "adsense_frame");
			ifrm.setAttribute("scrolling", "no");
			
			document.getElementById("sudoku_about_src").appendChild(ifrm);//inserts into div id at the end, the new content
			*/
			
		}
	}
	/*else if (load_more_content_flag==1)//next upload
	{
		var el=document.getElementById('upload_user_sudoku_div');
		var rect = el.getBoundingClientRect();
		var elemTop = rect.top;
		var elemBottom = rect.bottom;
		var isVisible = elemTop < window.innerHeight && elemBottom >= 0;

		if (isVisible) 
		{
			load_more_content_flag=2;
			user_sudoku_upload(2);
		}
	}
	else if (load_more_content_flag==2)//next upload
	{
		var el=document.getElementById('users_div');
		var rect = el.getBoundingClientRect();
		var elemTop = rect.top;
		var elemBottom = rect.bottom;
		var isVisible = elemTop < window.innerHeight && elemBottom >= 0;

		if (isVisible) 
		{
			load_more_content_flag=3;
			user_sudoku_upload(3);
		}
	}
	*/
}
function cpa_list()
{
	var xmlhttp;
	var params = "ln=cn";
	
if (window.XMLHttpRequest){
	xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject){
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else{
	alert("Your browser does not support XMLHTTP!");
}
xmlhttp.onreadystatechange=function()
{
	if(xmlhttp.readyState==4)
	{
		var txt =xmlhttp.responseText;
		document.getElementById("recommended_games").innerHTML =txt;
		//check width screen, for iphone safari
	}
}
xmlhttp.open("POST","ajax_cpa_list.php",true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(params);
}